package com.ghh.dao;

import com.ghh.pojo.Menu;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface MenuDao {

    //查询所有父类导航条信息
    @Select("select m.*,rm.role_id from t_menu m inner join t_role_menu rm on m.id=rm.menu_id where m.level=1 and rm.role_id =#{roleId}  ")
    @Results({
            @Result(column = "id",property = "id",id = true),
            @Result(property = "children", column = "id", many = @Many(select = "com.ghh.dao.MenuDao.findChildrenById"))
    })
    List<Menu> findAll(Integer roleId);

    //根据父类ID查询所有该父类的子类导航条
    @Select("select * from t_menu where parentMenuId = #{id}")
    List<Menu> findChildrenById(Integer id);

}
